#ifndef H_RCGD_COUNTER_H
#define H_RCGD_COUNTER_H

#define	OFFSET_QUEUE_SIZE	6

//#define	MAX_DETAIL_TABLE 500
//#define	MAX_DETAIL_INDEX 150

#define	MAX_DETAIL_TABLE 1024
#define	MAX_DETAIL_INDEX 200

#define	DETAIL_500	0
#define	DETAIL_50	1


typedef struct{
	double	offset[OFFSET_QUEUE_SIZE];
	double	difference[OFFSET_QUEUE_SIZE];

	int		index_in;
	int		index_out;
} counter_queue_;


typedef struct {
	double	dbConst;
	double	dbA;
	unsigned short range;
	unsigned short usMax;
	unsigned short usCenter;
	signed short * pTable;
	int		index;
	char	event;

} CalcDetail_;


extern unsigned int uiTemp;
extern OT_	CounterMonitorTable;
extern int	CounterMonitorCounter;
extern int	CounterMonitorCheckCounter;
extern char CounterMonitorFlag;

extern unsigned short	usCenterADC, usMaxADC;
extern unsigned short	usCenterADC_50ns, usMaxADC_50ns;
extern unsigned short	usCenterADC_500ns, usMaxADC_500ns;


extern signed short	Detail500Table[MAX_DETAIL_TABLE];
extern signed short	Detail50Table[MAX_DETAIL_TABLE];
extern signed short	ssDetailTable[MAX_DETAIL_TABLE];



extern double  TestOffset;

extern double 	RAW_DIFFERENCE, RAW_OFFSET;

extern double  Recovery_Offset;

extern void clear_counter_queue();

extern void MakeDetailTable(signed short *, unsigned short, unsigned short,unsigned short);


extern CalcDetail_		CalcDetail;
extern void calc_detail_table();

extern void PrintDetailTable();

extern int CurDetailIndex;


extern int MyReference;

extern double ModiValue;

extern double gCurrentAll;
extern double gCurrent;
extern double gDetail;
extern double gOffset1;
extern double dbRlt_global;

extern double gInputData;
extern double gOutputData;

extern double _raw_offset;
extern double _raw_difference;

/*#define	JITTER_OFFSET	6*/
#define	JITTER_OFFSET		7.5
#define	NO_JITTER_OFFSET	0.8
#define	JITTER_PROVE_OFFSET	NO_JITTER_OFFSET
#define	JITTER_PROVE_TIME	30

extern unsigned int skipping_change_eb;
extern unsigned int waiting_change_eb;
extern int err_10m_cnt;
extern char reset_eb_done;
extern char fail_eb_now;
extern int TEMP_RAW_DIGITS;

extern int last_ro_value;

extern void ReadDifferenceCount(void);
extern unsigned int start_monitor_39m;
void MointorCounterClear();
#endif
